//
//  CoinAssetCellSectionHeadView.m
//  AppleMarket
//
//  Created by yangy on 01/11/2018.
//  Copyright © 2018 szgsy. All rights reserved.
//

#import "CoinAssetCellSectionHeadView.h"

@interface CoinAssetCellSectionHeadView()
@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) UILabel *titlabel;
@property (nonatomic, strong) UIButton *hiidenButton;
@property (nonatomic, strong) UIView *blockView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *enabelLabel;
@property (nonatomic, strong) UILabel *disabelLabel;
@end

@implementation CoinAssetCellSectionHeadView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if(self){
        self.backgroundColor = [UIColor whiteColor];
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self initViews];
    }
    return self;
}

- (void) initViews
{
    [self.contentView addSubview:self.lineView];
    [self.contentView addSubview:self.lineView];
    [self.contentView addSubview:self.titlabel];
    [self.contentView addSubview:self.hiidenButton];
    [self.contentView addSubview:self.blockView];
    [self.blockView addSubview:self.nameLabel];
    [self.blockView addSubview:self.enabelLabel];
    [self.blockView addSubview:self.disabelLabel];
    [self setLayoutSubviews];
}

- (void) setLayoutSubviews
{
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self);
        make.left.right.mas_equalTo(self);
        make.height.mas_equalTo(10);
    }];
    
    [_titlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(15);
        make.top.mas_equalTo(self.lineView.mas_bottom).offset(20);
    }];
    
    [_hiidenButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.titlabel.mas_centerY);
        make.right.mas_equalTo(self.contentView).offset(-15);
    }];
    
    [_blockView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self);
        make.height.mas_equalTo(35);
        make.bottom.mas_equalTo(self.mas_bottom);
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.blockView).offset(15);
        make.centerY.mas_equalTo(self.blockView);
    }];
    
    [_enabelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.blockView);
        make.centerY.mas_equalTo(self.blockView);
    }];
    
    [_disabelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self).offset(-15);
        make.centerY.mas_equalTo(self.blockView);
    }];
}

- (UIView *)lineView
{
    if(!_lineView){
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = kColorWithHex(0xF7F9FC);
    }
    return _lineView;
}

- (UILabel *)titlabel
{
    if(!_titlabel){
        _titlabel = [UILabel cm_labelWithText:@"资产明细" font:kFont(16) textColor:kColorWithHex(0x4A647A)];
    }
    return _titlabel;
}

- (UIButton *)hiidenButton
{
    if(!_hiidenButton){
        _hiidenButton = [UIButton cm_ButtonWithTitle:@"隐藏0余额" font:kFont(13) titleColor:kColorWithHex(0x808C99)];
        [_hiidenButton setImage:[UIImage imageNamed:@"check_sel"] forState:UIControlStateSelected];
        [_hiidenButton setImage:[UIImage imageNamed:@"check_nor"] forState:UIControlStateNormal];
        [_hiidenButton setImagePosition:Left spacing:8];
        [[_hiidenButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            x.selected = !x.isSelected;
            if(self.buttonClickHandler){
                self.buttonClickHandler(x.isSelected);
            }
        }];
    }
    return _hiidenButton;
}

- (UIView *)blockView
{
    if(!_blockView){
        _blockView = [[UIView alloc] init];
        _blockView.backgroundColor = kColorWithHex(0xF7FBFC);
    }
    return _blockView;
}

- (UILabel *)nameLabel
{
    if(!_nameLabel){
        _nameLabel = [UILabel cm_labelWithText:@"币种" font:kFont(13) textColor:kColorWithHex(0xB5C0CB)];
    }
    return _nameLabel;
}

- (UILabel *)enabelLabel
{
    if(!_enabelLabel){
        _enabelLabel = [UILabel cm_labelWithText:@"可用" font:kFont(13) textColor:kColorWithHex(0xB5C0CB)];
    }
    return _enabelLabel;
}

- (UILabel *)disabelLabel
{
    if(!_disabelLabel){
        _disabelLabel = [UILabel cm_labelWithText:@"冻结" font:kFont(13) textColor:kColorWithHex(0xB5C0CB)];
    }
    return _disabelLabel;
}


@end
